package com.csgc.camera.util

import android.widget.TextView
import com.drake.spannable.addSpan
import com.drake.spannable.movement.ClickableMovementMethod
import com.drake.spannable.span.HighlightSpan


object PrivacyProtocolHelper {
    fun setupPrivacyProtocolText(
        textView: TextView,
        privacyColor: Int,
        protocolClickListener: (() -> Unit)? = null,
        privacyClickListener: (() -> Unit)? = null
    ) {
        textView.text = "开通前请阅读"
            .addSpan("《会员服务协议》", listOf(HighlightSpan(color = privacyColor, onClick = {
                protocolClickListener?.invoke()
            })))
            .addSpan("及")
            .addSpan("《自动续费服务规则》", listOf(HighlightSpan(color = privacyColor, onClick = {
                privacyClickListener?.invoke()
            })))
        textView.movementMethod = ClickableMovementMethod()
    }
}